Remove useless returns
authormcarton <cartonmartin+git@gmail.com>
Fri, 15 Jan 2016 14:51:25 +0000 (15:51 +0100)
committermcarton <cartonmartin+git@gmail.com>
Sat, 16 Jan 2016 11:42:56 +0000 (12:42 +0100)
Fix most of Clippy’s needless_return warnings. Remaining cases are
false positives.

12 files changed:
src/cargo/core/resolver/mod.rs
src/cargo/core/shell.rs
src/cargo/ops/cargo_compile.rs
src/cargo/ops/cargo_rustc/context.rs
src/cargo/ops/cargo_rustc/custom_build.rs
src/cargo/ops/cargo_rustc/fingerprint.rs
src/cargo/sources/git/source.rs
src/cargo/sources/path.rs
src/cargo/sources/registry.rs
src/cargo/util/config.rs
src/cargo/util/sha256.rs
src/cargo/util/vcs.rs

index 547d7e23f8a5c60480b06defb5ea89569d54a4ab..5e2dc39a0c72536569d2061dbd254f9f0638f420 100644 (file)
@@ -384,7 +384,7 @@ fn find_candidate(backtrack_stack: &mut Vec<BacktrackFrame>,
             return Some(candidate)
         }
     }
-    return None
+    None
 }
 
 #[allow(deprecated)] // connect => join in 1.3
index 5c03d34c16e519346fb2aaaf22c75b3ae5a38ce0..5a50a98860fbff826a11ce92455f170cc630a70a 100644 (file)
@@ -81,7 +81,7 @@ impl MultiShell {
         where F: FnMut(&mut MultiShell) -> io::Result<()>
     {
         match self.verbosity {
-            Verbose => return callback(self),
+            Verbose => callback(self),
             _ => Ok(())
         }
     }
@@ -91,7 +91,7 @@ impl MultiShell {
     {
         match self.verbosity {
             Verbose => Ok(()),
-            _ => return callback(self)
+            _ => callback(self)
         }
     }
 
index f80e3db2bfd965c99fc7649c82db9e9ed1a7b08f..43995c0d0531f9b37bbfc1cb4e7dee4b12efef6e 100644 (file)
@@ -257,7 +257,7 @@ pub fn compile_pkg<'a>(root_package: &Package,
 
     ret.to_doc_test = to_builds.iter().map(|&p| p.clone()).collect();
 
-    return Ok(ret);
+    Ok(ret)
 }
 
 impl<'a> CompileFilter<'a> {
@@ -311,7 +311,7 @@ fn generate_targets<'a>(pkg: &'a Package,
         CompileMode::Build => build,
         CompileMode::Doc { .. } => &profiles.doc,
     };
-    return match *filter {
+    match *filter {
         CompileFilter::Everything => {
             match mode {
                 CompileMode::Bench => {
@@ -379,7 +379,7 @@ fn generate_targets<'a>(pkg: &'a Package,
             }
             Ok(targets)
         }
-    };
+    }
 }
 
 /// Read the `paths` configuration variable to discover all path overrides that
index a1bc8b3a692e58c045afad64e2de6c42b4e98c7b..716e04490154818dfa13bfc365bb6b9331cbd25e 100644 (file)
@@ -159,7 +159,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
         self.compilation.deps_output =
                 self.layout(root, Kind::Target).proxy().deps().to_path_buf();
 
-        return Ok(());
+        Ok(())
     }
 
     /// Returns the appropriate directory layout for either a plugin or not.
@@ -283,7 +283,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
             }
         }
         assert!(ret.len() > 0);
-        return Ok(ret);
+        Ok(ret)
     }
 
     /// For a package, return all targets which are registered as dependencies
@@ -374,7 +374,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
                 }
             }));
         }
-        return ret
+        ret
     }
 
     /// Returns the dependencies needed to run a build script.
@@ -462,7 +462,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
         if unit.target.is_bin() {
             ret.extend(self.maybe_lib(unit));
         }
-        return ret
+        ret
     }
 
     /// If a build script is scheduled to be run for the package specified by
index 9b974ab1cd3249778e005179cd4064d6eeaed342..ea06cf570c32c3639853b41168ee733526096a18 100644 (file)
@@ -399,6 +399,6 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>,
         let prev = out.entry(*unit).or_insert(BuildScripts::default());
         prev.to_link.extend(to_link);
         prev.plugins.extend(plugins);
-        return prev
+        prev
     }
 }
index 1cd37c33c62fae7e3c875b063b06c6bba2364d65..66f0fb0ddd349f4907266881e2e789273c675ab3 100644 (file)
@@ -141,7 +141,7 @@ impl Fingerprint {
         }
         let ret = util::hash_u64(self);
         *self.memoized_hash.lock().unwrap() = Some(ret);
-        return ret
+        ret
     }
 
     fn compare(&self, old: &Fingerprint) -> CargoResult<()> {
index eaf66adccfb0739e506558e1f0e462c7360a3e96..e2829ad5be7d2bfaf6a28040ebed10fcc8c230a4 100644 (file)
@@ -145,7 +145,7 @@ pub fn canonicalize_url(url: &Url) -> Url {
         _ => {}
     }
 
-    return url;
+    url
 }
 
 impl<'cfg> Debug for GitSource<'cfg> {
index 91162a5fe6a1deeaf9ecdf0e53687c486ab244a2..1cbead449314472e38baf6ba38f4cb192ac12a39 100644 (file)
@@ -244,7 +244,7 @@ impl<'cfg> PathSource<'cfg> {
             let loc = pkg.root();
             try!(PathSource::walk(loc, &mut ret, true, filter));
         }
-        return Ok(ret);
+        Ok(ret)
     }
 
     fn walk(path: &Path, ret: &mut Vec<PathBuf>,
@@ -275,7 +275,7 @@ impl<'cfg> PathSource<'cfg> {
             }
             try!(PathSource::walk(&dir, ret, false, filter));
         }
-        return Ok(())
+        Ok(())
     }
 }
 
index 7a7822a670b47582c23224610ac845ff49f18fef..9bce0dc252aa257c91408c88c01c9b42c4184179 100644 (file)
@@ -561,7 +561,7 @@ impl<'cfg> Source for RegistrySource<'cfg> {
         for src in self.sources.values() {
             ret.extend(try!(src.get(packages)).into_iter());
         }
-        return Ok(ret);
+        Ok(ret)
     }
 
     fn fingerprint(&self, pkg: &Package) -> CargoResult<String> {
index 474b174f1b7ebea086186a97a0d849573ae4e36e..88a42383be0e0c4ebd74b8657f3b245a9d62513b 100644 (file)
@@ -469,7 +469,7 @@ fn homedir(cwd: &Path) -> Option<PathBuf> {
         cwd.join(home)
     });
     let user_home = env::home_dir().map(|p| p.join(".cargo"));
-    return cargo_home.or(user_home);
+    cargo_home.or(user_home)
 }
 
 fn walk_tree<F>(pwd: &Path, mut walk: F) -> CargoResult<()>
index 3a6dc5055b75e583a73c054cebd517d0cfbf2713..18a258af3161be9f001be494cfe6ea889f8c30af 100644 (file)
@@ -36,7 +36,7 @@ mod imp {
                 let ret = Sha256 { ctx: ctx };
                 let n = EVP_DigestInit_ex(ret.ctx, EVP_sha256(), 0 as *mut _);
                 assert_eq!(n, 1);
-                return ret;
+                ret
             }
         }
 
@@ -55,7 +55,7 @@ mod imp {
                 let n = EVP_DigestFinal_ex(self.ctx, ret.as_mut_ptr(), &mut out);
                 assert_eq!(n, 1);
                 assert_eq!(out, 32);
-                return ret;
+                ret
             }
         }
     }
@@ -104,7 +104,7 @@ mod imp {
                 CryptCreateHash(ret.hcryptprov, CALG_SHA_256,
                                 0, 0, &mut ret.hcrypthash)
             });
-            return ret;
+            ret
         }
 
         pub fn update(&mut self, bytes: &[u8]) {
@@ -122,7 +122,7 @@ mod imp {
                                   &mut len, 0)
             });
             assert_eq!(len as usize, ret.len());
-            return ret;
+            ret
         }
     }
 
index 16fc723333826b96d080916eadb1c0e803a2f343..ffd260680a26d9fc44170e9592c8f0cccff2db89 100644 (file)
@@ -10,7 +10,7 @@ pub struct GitRepo;
 impl GitRepo {
     pub fn init(path: &Path, _: &Path) -> CargoResult<GitRepo> {
         try!(git2::Repository::init(path));
-        return Ok(GitRepo)
+        Ok(GitRepo)
     }
     pub fn discover(path: &Path, _: &Path) -> Result<git2::Repository,git2::Error> {
         git2::Repository::discover(path)
@@ -20,11 +20,11 @@ impl GitRepo {
 impl HgRepo {
     pub fn init(path: &Path, cwd: &Path) -> CargoResult<HgRepo> {
         try!(process("hg").cwd(cwd).arg("init").arg(path).exec());
-        return Ok(HgRepo)
+        Ok(HgRepo)
     }
     pub fn discover(path: &Path, cwd: &Path) -> CargoResult<HgRepo> {
         try!(process("hg").cwd(cwd).arg("root").cwd(path).exec_with_output());
-        return Ok(HgRepo)
+        Ok(HgRepo)
     }
 }